package com.zr.rocketmq.consumer;

import com.zr.rocketmq.entity.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
// 消费延迟订单消息
@RocketMQMessageListener(topic = "order_topic", consumerGroup = "delay_order_consumer_group", selectorExpression = "delay")
public class DelayOrderConsumer implements RocketMQListener<Order> {

    @Override
    public void onMessage(Order order) {
        log.info("收到延迟订单消息，开始处理...");
        log.info("订单ID: {}", order.getOrderId());
        log.info("当前时间: {}", new java.util.Date());
        
        // 这里可以添加超时订单处理逻辑，如取消订单、恢复库存等
        log.info("超时订单处理完成，状态更新为CANCELLED");
    }
}
